/*
 * Edit.h
 *
 *  Created on: 2012-10-21
 *      Author: yangentao@gmail.com
 */

#ifndef EDIT_H_
#define EDIT_H_
#include "headers.h"
#include "SysControl.h"

enum TextAlign {
	textAlignLeft,
	textAlignRight,
	textAlignCenter,
};

enum BalloonTipIcon {
	editTipIconError,
	editTipIconInfo,
	editTipIconWarning,
#if (_WIN32_WINNT >= 0x0600)
	editTipIconErrorLarge,
	editTipIconInfoLarge,
	editTipIconWarningLarge,
#endif
};

class Edit: public SysControl {
	typedef SysControl Super;
public:
	Edit();
	virtual ~Edit();
protected:
	DWORD getDefaultExStyle();
	DWORD getDefaultStyle();
	LPCTSTR getClassName();
	DWORD getDefaultMultiLineStyle();
public:
	bool create(HWND parent, Rect rect, UINT id);
public:
	void setAutoHScroll(bool autoHScroll);
	void setAutoVScroll(bool autoVScroll);
	void setTextAlign(TextAlign align);
	void setLowercase(bool lowerCase);
	void setUppercase(bool upperCase);
	void setMultiLine(bool multiLine);
	void setNoHideSelect(bool noHideSel);
	void setNumber(bool num);
	void setPassword(bool password);
	void setReadOnly(bool readOnly);
	void setWantReturn(bool wantReturn);

public:
#if (_WIN32_WINNT >= 0x0600)
	//CueBannerText, vista+
	void setHint(LPCWSTR hint);
	//CueBannerText
	WString getHint();
#endif

	//Comclt32.dll version 6.0
	void showBalloonTip(LPCWSTR title, LPCWSTR text, BalloonTipIcon icon = editTipIconInfo);
	void hideBalloonTip();
public:
	bool canUndo();
	int charFromPos(int x, int y);
	int charFromPos(int x, int y, int& lineNO);
	void clearUndoBuffer();
	//soft line break, effect only on GetText/getHandle
	void setAutoWrapWhenGetText(bool autoWrap);
};

#endif /* EDIT_H_ */
